<?php
/**
 * Created by PhpStorm.
 * User: xpz
 * Date: 2021/11/18
 * Time: 16:51
 */

namespace app\common\model;
use think\Model;
use think\config;

class Record extends Model
{
    // 开启自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';
    // 定义时间戳字段名
    protected $createTime = '';
    protected $updateTime = '';


    public function getTypeNameAttr($value, $data)
    {
        if(!empty($data['type2'])){
            if($data['type'] == 0){//支出
                return getzhifunamebyid($data['type2']);
            } else {
                return getshourunamebyid($data['type2']);
            }

        } else {
            return "";
        }
    }

    public function getTypeMarkAttr($value, $data)
    {
        if(!empty($data['type2'])){
            if($data['type'] == 0){//支出
                return "-";
            } else {
                return "+";
            }

        } else {
            return "";
        }
    }


    public function getTypeIconAttr($value, $data)
    {
        if(!empty($data['type2'])){
            if($data['type'] == 0){//支出
                return getzhifuiconbyid($data['type2']);
//                return getDomain().$zhifuIconArr[$data['type2']];
            } else {
                return getshouruiconbyid($data['type2']);
//                return getDomain().$shouruIconArr[$data['type2']];
            }

        } else {
            return "";
        }
    }

    public function getAddTimeFormatAttr($value, $data)
    {
        if(!empty($data['add_time'])){

            return date("Y-m-d H:i:s",$data['add_time']);
        } else {
            return "";
        }
    }
    public function getUpdateTimeAttr($value, $data)
    {
        if(!empty($data['update_time'])){

            return date("Y-m-d H:i:s",$data['update_time']);
        } else {
            return "";
        }
    }
    public function getFullImageAttr($value, $data)
    {
        if(!empty($data['image'])){

            return getDomain().$data['image'];
        } else {
            return "";
        }
    }


}